<template>
    <input
    :type="type"
    data-slot="input"
    :class="cn(
      'file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground bg-input-background dark:bg-input/50 border-2 border-border flex h-9 w-full min-w-0 rounded-md px-3 py-1 text-base backdrop-blur-sm shadow-sm transition-[color,box-shadow,border-color] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm',
      'focus-visible:border-primary/50 focus-visible:ring-primary/20 focus-visible:ring-[3px]',
      'aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive',
      className
    )"
    :value="props.modelValue"
    @input="onInput"
    v-bind="$attrs"
  />
</template>

<script setup>
import { cn } from '../utils'

const props = defineProps({
  type: {
    type: String,
    default: 'text'
  },
  className: {
    type: String,
    default: ''
  },
  modelValue: {
    type: [String, Number],
    default: ''
  }
})

const emit = defineEmits(['update:modelValue'])

const onInput = (event) => {
  emit('update:modelValue', event.target.value)
}
</script>
